home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 676-700 / 683 / printfiles / source.lha / Source / prf_saveprefs.c < prev    next >
C/C++ Source or Header  |  1992-06-16  |  14KB  |  388 lines

  1. /* prf_saveprefs.c */
  2. /* V091 9-3-92 */
  3.  
  4. #include "prf.h"
  5.  
  6. UWORD chip saveprefsiconI1Data[] =
  7. {
  8. /* Plane 0 */
  9.     0x0000,0x0000,0x0000,0x7FFF,0xFFFF,0xFFFC,0x7FE0,0x0000,
  10.     0x07FC,0x7FE4,0x4688,0x07FC,0x7FE0,0x0000,0x07FC,0x7FE7,
  11.     0xF580,0x07FC,0x7FE0,0x0000,0x07FC,0x7FE7,0xFFFD,0x87FC,
  12.     0x7FE6,0x0000,0x07FC,0x7FE3,0x7F00,0x07FC,0x7FFF,0xFFFF,
  13.     0xFFFC,0x7000,0x0000,0x000C,0x77FF,0xFFFF,0xFFEC,0x77FF,
  14.     0xFFFF,0xB6EC,0x77FF,0xFFFF,0xFFEC,0x77FF,0xFFFF,0xFFEC,
  15.     0x7000,0x0000,0x000C,0x7FFF,0xFFFF,0xFFFC,0x7FF0,0x3FFE,
  16.     0x7FFC,0x7FFB,0x9FFD,0xFFFC,0x7FFB,0xDFFD,0xFFFC,0x7FFB,
  17.     0x8998,0xC7FC,0x7FF8,0x336D,0xB7FC,0x7FFB,0xF70D,0x9FFC,
  18.     0x7FFB,0xF77D,0xE7FC,0x7FFB,0xF735,0xB7FC,0x7FF1,0xE38D,
  19.     0x8FFC,0x7FFF,0xFFFF,0xFFFC,0x0000,0x0000,0x0000,
  20. /* Plane 1 */
  21.     0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,
  22.     0xFFFE,0xFFFB,0xB977,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFF8,
  23.     0x0A7F,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFF8,0x0002,0x7FFE,
  24.     0xFFF9,0xFFFF,0xFFFE,0xFFFC,0x80FF,0xFFFE,0xFFE0,0x0000,
  25.     0x03FE,0xFFFF,0xFFFF,0xFFFE,0xF800,0x0000,0x001E,0xF800,
  26.     0x0000,0x491E,0xF800,0x0000,0x001E,0xF800,0x0000,0x001E,
  27.     0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,
  28.     0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFF,
  29.     0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,
  30.     0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,
  31.     0xFFFE,0xFFFF,0xFFFF,0xFFFE,0xFFFF,0xFFFF,0xFFFE,
  32. };
  33.  
  34. struct Image saveprefsiconI1 =
  35. {
  36.     0, 0,                       /* Upper left corner */
  37.     47, 29, 2,                  /* Width, Height, Depth */
  38.     saveprefsiconI1Data,                /* Image data */
  39.     0x0003, 0x0000,             /* PlanePick, PlaneOnOff */
  40.     NULL                        /* Next image */
  41. };
  42.  
  43. UBYTE *saveprefsimageTools[] =
  44. {
  45.     "CONSOLE=con:0/0/100/100/PrintFiles/AUTO",
  46.     "DONOTWAIT",
  47.     NULL
  48. };
  49.  
  50. struct DiskObject saveprefsicon =
  51. {
  52.     WB_DISKMAGIC,               /* Magic Number */
  53.     WB_DISKVERSION,             /* Version */
  54.     {                           /* Embedded Gadget Structure */
  55.         NULL,                   /* Next Gadget Pointer */
  56.         0, 0, 47, 30,           /* Left,Top,Width,Height */
  57.         GADGIMAGE | GADGBACKFILL,       /* Flags */
  58.         RELVERIFY,              /* Activation Flags */
  59.         BOOLGADGET,             /* Gadget Type */
  60.         (APTR)&saveprefsiconI1, /* Render Image */
  61.         NULL,                   /* Select Image */
  62.         NULL,                   /* Gadget Text */
  63.         NULL,                   /* Mutual Exclude */
  64.         NULL,                   /* Special Info */
  65.         0,                      /* Gadget ID */
  66.         NULL,                   /* User Data */
  67.     },
  68.     WBPROJECT,                  /* Icon Type */
  69.     (char *)"SYS:rexxc/rx",     /* Default Tool */
  70.     saveprefsimageTools,        /* Tool Type Array */
  71.     NO_ICON_POSITION,           /* Current X */
  72.     NO_ICON_POSITION,           /* Current Y */
  73.     NULL,                       /* Drawer Structure */
  74.     NULL,                       /* Tool Window */
  75.     0                           /* Stack Size */
  76. };
  77.  
  78.  
  79. struct st
  80.        {
  81.         UBYTE *line;
  82.         UBYTE *comment;
  83.        };
  84.  
  85. static struct st start_text[] =
  86.        {
  87.         START_L1,COMMENT_L1,
  88.         START_L2,COMMENT_L2,
  89.         START_L3,COMMENT_L3,
  90.         START_L4,COMMENT_L4,
  91.         START_L5,COMMENT_L5,
  92.         START_L6,COMMENT_L6,
  93.         NULL,NULL,
  94.        };
  95.  
  96. void  __regargs SavePreferences(struct prf_info *info,UBYTE *name)
  97. {
  98.  FILE *prefs;
  99.  UBYTE filename[STR_SIZE];
  100.  UBYTE *sp = "             ";
  101.  struct FileNameNode *n;
  102.  strcpy(sp,"-CFWSRPIL");
  103.  if(name) strcpy(filename,name);
  104.   else Prf_SavePrefs(info,filename);
  105.  if(info->Swd)
  106.  {
  107.   SwdTags[0].ti_Data = (ULONG)info->Swd->LeftEdge;
  108.   SwdTags[1].ti_Data = (ULONG)info->Swd->TopEdge;
  109.  }
  110.  if(*filename)
  111.  {
  112.   if(prefs = fopen(filename,"w"))
  113.   {
  114.    fprintf(prefs,T_PREFSHEADER);
  115.    if(info->flags.sp_start)
  116.    {
  117.     long i = 0L;
  118.     fprintf(prefs,("\n"));
  119.     while(start_text[i].line)
  120.     {
  121.      fprintf(prefs,"%s ",start_text[i].line);
  122.      if(info->flags.sp_comment)
  123.        fprintf(prefs,"%s ",start_text[i].comment);
  124.      fprintf(prefs,("\n"));
  125.      i++;
  126.     }
  127.     fprintf(prefs,("\n"));
  128.    }
  129.    else fprintf(prefs,T_PREFSHEADER1);
  130.    fprintf(prefs,T_PREFSHEADER2);
  131.    if(info->flags.sp_reset)
  132.     if(info->flags.sp_comment)
  133.             fprintf(prefs, T_RX_RESET RT_RX_RESET"\n");
  134.     else    fprintf(prefs, T_RX_RESET "\n");
  135.    if(info->flags.cpi == 1)
  136.     if(info->flags.sp_comment)
  137.            fprintf(prefs, T_RX_10CPI RT_RX_10CPI"\n");
  138.     else   fprintf(prefs, T_RX_10CPI "\n");
  139.    if(info->flags.cpi == 2)
  140.     if(info->flags.sp_comment)
  141.            fprintf(prefs, T_RX_12CPI RT_RX_12CPI "\n");
  142.     else   fprintf(prefs, T_RX_12CPI  "\n");
  143.    if(info->flags.cpi == 3)
  144.     if(info->flags.sp_comment)
  145.            fprintf(prefs, T_RX_15CPI RT_RX_15CPI "\n");
  146.     else   fprintf(prefs, T_RX_15CPI  "\n");
  147.    if(info->flags.draft)
  148.      if(info->flags.sp_comment)
  149.            fprintf(prefs, T_RX_DRAFT RT_RX_DRAFT "\n");
  150.      else  fprintf(prefs, T_RX_DRAFT  "\n");
  151.    if(info->flags.lq)
  152.     if(info->flags.sp_comment)
  153.            fprintf(prefs, T_RX_LQ RT_RX_LQ "\n");
  154.     else   fprintf(prefs, T_RX_LQ "\n");
  155.    if(info->flags.page)
  156.    {
  157.     if(info->flags.sp_comment)
  158.            fprintf(prefs, T_RX_PAGE " " T_RX_ON " " RT_RX_PAGE "\n");
  159.     else   fprintf(prefs, T_RX_PAGE " " T_RX_ON "\n");
  160.    }
  161.    else
  162.    {
  163.     if(info->flags.sp_comment)
  164.            fprintf(prefs, T_RX_PAGE " " T_RX_OFF " " RT_RX_PAGE "\n");
  165.     else   fprintf(prefs, T_RX_PAGE " " T_RX_OFF "\n");
  166.    }
  167.    if(info->flags.time)
  168.    {
  169.     if(info->flags.sp_comment)
  170.           fprintf(prefs, T_RX_TIME " " T_RX_ON " " RT_RX_TIME "\n");
  171.     else  fprintf(prefs, T_RX_TIME " " T_RX_ON "\n");
  172.    }
  173.    else
  174.    {
  175.     if(info->flags.sp_comment)
  176.           fprintf(prefs, T_RX_TIME " " T_RX_OFF " " RT_RX_TIME "\n");
  177.     else  fprintf(prefs, T_RX_TIME " " T_RX_OFF "\n");
  178.    }
  179.    if(info->flags.file)
  180.    {
  181.     if(info->flags.sp_comment)
  182.            fprintf(prefs, T_RX_FILE " " T_RX_ON " " RT_RX_FILE "\n");
  183.     else   fprintf(prefs, T_RX_FILE " " T_RX_ON "\n");
  184.    }
  185.    else
  186.    {
  187.     if(info->flags.sp_comment)
  188.            fprintf(prefs, T_RX_FILE " " T_RX_OFF " " RT_RX_FILE "\n");
  189.     else   fprintf(prefs, T_RX_FILE " " T_RX_OFF "\n");
  190.    }
  191.    if(info->flags.line)
  192.    {
  193.     if(info->flags.sp_comment)
  194.            fprintf(prefs, T_RX_LINE " " T_RX_ON " " RT_RX_LINE "\n");
  195.     else   fprintf(prefs, T_RX_LINE " " T_RX_ON  "\n");
  196.    }
  197.    else
  198.    {
  199.     if(info->flags.sp_comment)
  200.            fprintf(prefs, T_RX_LINE " " T_RX_OFF " " RT_RX_LINE "\n");
  201.     else   fprintf(prefs, T_RX_LINE " " T_RX_OFF "\n");
  202.    }
  203.    if(info->flags.date)
  204.    {
  205.     if(info->flags.sp_comment)
  206.            fprintf(prefs, T_RX_DATE " " T_RX_ON " " RT_RX_DATE "\n");
  207.     else   fprintf(prefs, T_RX_DATE " " T_RX_ON "\n");
  208.    }
  209.    else
  210.    {
  211.     if(info->flags.sp_comment)
  212.            fprintf(prefs, T_RX_DATE " " T_RX_OFF " " RT_RX_DATE "\n");
  213.     else   fprintf(prefs, T_RX_DATE " " T_RX_OFF "\n");
  214.    }
  215.    if(info->flags.pitch == 1)
  216.     if(info->flags.sp_comment)
  217.            fprintf(prefs, T_RX_PITCH6 RT_RX_PITCH6 "\n");
  218.     else   fprintf(prefs, T_RX_PITCH6 "\n");
  219.    if(info->flags.pitch == 2)
  220.     if(info->flags.sp_comment)
  221.            fprintf(prefs, T_RX_PITCH8 RT_RX_PITCH8 "\n");
  222.     else   fprintf(prefs, T_RX_PITCH8 "\n");
  223.    if(info->flags.ff)
  224.    {
  225.     if(info->flags.sp_comment)
  226.            fprintf(prefs, T_RX_FF " " T_RX_ON " " RT_RX_FF "\n");
  227.    else    fprintf(prefs, T_RX_FF " " T_RX_ON "\n");
  228.    }
  229.    else
  230.    {
  231.     if(info->flags.sp_comment)
  232.            fprintf(prefs, T_RX_FF " " T_RX_OFF " " RT_RX_FF "\n");
  233.    else    fprintf(prefs, T_RX_FF " " T_RX_OFF "\n");
  234.    }
  235.    if(info->flags.ffpage)
  236.    {
  237.     if(info->flags.sp_comment)
  238.            fprintf(prefs, T_RX_FFPAGE " " T_RX_ON " " RT_RX_FFPAGE "\n");
  239.     else   fprintf(prefs, T_RX_FFPAGE " " T_RX_ON "\n");
  240.    }
  241.    else
  242.    {
  243.     if(info->flags.sp_comment)
  244.            fprintf(prefs, T_RX_FFPAGE " " T_RX_OFF " " RT_RX_FFPAGE "\n");
  245.     else   fprintf(prefs, T_RX_FFPAGE " " T_RX_OFF "\n");
  246.    }
  247.     if(info->flags.sp_lines)
  248.     {
  249.      if(info->flags.sp_comment)
  250.             fprintf(prefs, "%s '%s'" RT_RX_HEAD "\n", T_RX_HEAD,info->Headline);
  251.      else   fprintf(prefs, "%s '%s'"  "\n", T_RX_HEAD,info->Headline);
  252.      if(info->flags.sp_comment)
  253.             fprintf(prefs, "%s '%s'" RT_RX_FOOT "\n", T_RX_FOOT,info->Footline);
  254.      else   fprintf(prefs, "%s '%s'" "\n", T_RX_FOOT,info->Footline);
  255.     }
  256.     if(info->flags.sp_comment)
  257.            fprintf(prefs, "%s %ld" RT_RX_LMARGIN "\n",T_RX_LMARGIN,info->Lmargin);
  258.     else   fprintf(prefs, "%s %ld" "\n",T_RX_LMARGIN,info->Lmargin);
  259.     if(info->flags.sp_comment)
  260.            fprintf(prefs, "%s %ld" RT_RX_RMARGIN "\n",T_RX_RMARGIN,info->Rmargin);
  261.     else   fprintf(prefs, "%s %ld"  "\n",T_RX_RMARGIN,info->Rmargin);
  262.     if(info->flags.sp_comment)
  263.            fprintf(prefs, "%s %ld" RT_RX_LINES "\n",T_RX_LINES,info->Lines);
  264.     else   fprintf(prefs, "%s %ld"  "\n",T_RX_LINES,info->Lines);
  265.     if(info->flags.sp_files)
  266.     {
  267.      n = (struct FileNameNode *)info->FileList.lh_Head;
  268.      while(n && (n != (struct FileNameNode *)info->FileList.lh_Tail))
  269.      {
  270.       if(*(n->fnn_Name))
  271.       {
  272.        if(info->flags.sp_comment)
  273.           fprintf(prefs,  "%s '%s'" RT_RX_INSFILE "\n", T_RX_INSFILE,n->fnn_Name);
  274.        else fprintf(prefs,  "%s '%s'"  "\n", T_RX_INSFILE,n->fnn_Name);
  275.       }
  276.       n = (struct FileNameNode *)n->fnn_Node.ln_Succ;
  277.      }
  278.     }
  279.    if(info->flags.sp_window)
  280.    {
  281.     if(info->flags.sp_comment)
  282.     {
  283.      fprintf(prefs, T_RX_OPENWINDOW " " T_RX_CONTROL " %ld %ld " RT_RX_OPENWINDOW "\n",SwdTags[0].ti_Data,SwdTags[1].ti_Data);
  284.      fprintf(prefs, T_RX_OPENWINDOW " " T_RX_PREFS " %ld %ld " RT_RX_OPEN_P_WINDOW "\n",PwdTags[0].ti_Data,PwdTags[1].ti_Data);
  285.     }
  286.     else
  287.     {
  288.      fprintf(prefs, T_RX_OPENWINDOW " " T_RX_CONTROL " %ld %ld \n",SwdTags[0].ti_Data,SwdTags[1].ti_Data);
  289.      fprintf(prefs, T_RX_OPENWINDOW " " T_RX_PREFS " %ld %ld \n",PwdTags[0].ti_Data,PwdTags[1].ti_Data);
  290.     }
  291.    }
  292.    fprintf(prefs, T_RX_SAVEPREFS );
  293.    if(info->flags.sp_comment)*(sp + 1) = tolower(*(sp+1));
  294.    if(info->flags.sp_files)  *(sp + 2) = tolower(*(sp+2));
  295.    if(info->flags.sp_window) *(sp + 3) = tolower(*(sp+3));
  296.    if(info->flags.sp_start)  *(sp + 4) = tolower(*(sp+4));
  297.    if(info->flags.sp_reset)  *(sp + 5) = tolower(*(sp+5));
  298.    if(info->flags.sp_print)  *(sp + 6) = tolower(*(sp+6));
  299.    if(info->flags.sp_icon)   *(sp + 7) = tolower(*(sp+7));
  300.    if(info->flags.sp_lines)  *(sp + 8) = tolower(*(sp+8));
  301.    fprintf(prefs," '%s' ",sp);
  302.    if(info->flags.sp_comment)
  303.    {
  304.     fprintf(prefs," " RT_RX_SAVEPREFS "\n");
  305.     if(*(sp + 1) == 'c') fprintf(prefs, RT_RX_SP_ON " " RT_RX_SP_COMMENT "\n");
  306.      else fprintf(prefs,RT_RX_SP_OFF " " RT_RX_SP_COMMENT "\n");
  307.     if(*(sp + 2) == 'f') fprintf(prefs, RT_RX_SP_ON " " RT_RX_SP_FILES "\n");
  308.      else fprintf(prefs,RT_RX_SP_OFF " " RT_RX_SP_FILES "\n");
  309.     if(*(sp + 3) == 'w') fprintf(prefs, RT_RX_SP_ON " " RT_RX_SP_WINDOW "\n");
  310.      else fprintf(prefs,RT_RX_SP_OFF " " RT_RX_SP_WINDOW "\n");
  311.     if(*(sp + 4) == 's') fprintf(prefs, RT_RX_SP_ON " " RT_RX_SP_START "\n");
  312.      else fprintf(prefs,RT_RX_SP_OFF " " RT_RX_SP_START "\n");
  313.     if(*(sp + 5) == 'r') fprintf(prefs, RT_RX_SP_ON " " RT_RX_SP_RESET "\n");
  314.      else fprintf(prefs,RT_RX_SP_OFF " " RT_RX_SP_RESET "\n");
  315.     if(*(sp + 6) == 'p') fprintf(prefs, RT_RX_SP_ON " " RT_RX_SP_PRINT "\n");
  316.      else fprintf(prefs,RT_RX_SP_OFF " " RT_RX_SP_PRINT "\n");
  317.     if(*(sp + 7) == 'i') fprintf(prefs, RT_RX_SP_ON " " RT_RX_SP_ICON "\n");
  318.      else fprintf(prefs,RT_RX_SP_OFF " "  RT_RX_SP_ICON "\n");
  319.     if(*(sp + 8) == 'l') fprintf(prefs, RT_RX_SP_ON " " RT_RX_SP_LINES "\n");
  320.      else fprintf(prefs,RT_RX_SP_OFF " "  RT_RX_SP_LINES "\n");
  321.    }
  322.    else fprintf(prefs,"\n");
  323.    fprintf(prefs, T_RX_ICON " ");
  324.    switch(info->flags.icon)
  325.    {
  326.     case 0: if(info->flags.sp_comment)
  327.             fprintf(prefs,T_RX_IGNORE " " RT_RX_ICON_NONE "\n");
  328.              else
  329.               fprintf(prefs,T_RX_IGNORE "\n");
  330.             break;
  331.     case 1: if(info->flags.sp_comment)
  332.             fprintf(prefs,T_RX_CGFX " " RT_RX_ICON_IMAGE "\n");
  333.              else
  334.               fprintf(prefs,T_RX_CGFX "\n");
  335.             break;
  336.     case 2: if(info->flags.sp_comment)
  337.             fprintf(prefs,T_RX_INFO " " RT_RX_ICON_TEXT "\n");
  338.              else
  339.               fprintf(prefs,T_RX_INFO "\n");
  340.             break;
  341.     case 3: if(info->flags.sp_comment)
  342.             fprintf(prefs,T_RX_ALL " " RT_RX_ICON_ALL "\n");
  343.              else
  344.               fprintf(prefs,T_RX_ALL "\n");
  345.             break;
  346.    }
  347.    fprintf(prefs, T_RX_PROG " ");
  348.    switch(info->flags.prog)
  349.    {
  350.     case 0: if(info->flags.sp_comment)
  351.             fprintf(prefs,T_RX_IGNORE " " RT_RX_PROG_NONE "\n");
  352.              else
  353.               fprintf(prefs,T_RX_IGNORE "\n");
  354.             break;
  355.     case 1: if(info->flags.sp_comment)
  356.             fprintf(prefs,T_RX_INFO " " RT_RX_PROG_TEXT "\n");
  357.              else
  358.               fprintf(prefs,T_RX_INFO "\n");
  359.             break;
  360.     case 2: if(info->flags.sp_comment)
  361.             fprintf(prefs,T_RX_GFX " " RT_RX_PROG_ICON "\n");
  362.              else
  363.               fprintf(prefs,T_RX_GFX "\n");
  364.             break;
  365.     case 3: if(info->flags.sp_comment)
  366.             fprintf(prefs,T_RX_ALL " " RT_RX_PROG_ALL "\n");
  367.              else
  368.               fprintf(prefs,T_RX_ALL "\n");
  369.             break;
  370.    }
  371.    if(info->flags.sp_print)
  372.    {
  373.     if(info->flags.sp_comment)
  374.           fprintf(prefs, T_RX_PRINT RT_RX_PRINT "\n");
  375.     else  fprintf(prefs, T_RX_PRINT  "\n");
  376.    }
  377.    fclose(prefs);
  378.   }
  379.  }
  380.  if(info->flags.sp_icon)
  381.  {
  382.   if(*filename)PutDiskObject(filename,&saveprefsicon);
  383.  }
  384. }
  385.  
  386.  
  387.  
  388.